#include<bits/stdc++.h>
using namespace std;
#define ll long long

int a,x[100001];ll ans;

inline int read(){
    int s=1;
    int a=0;
    char d=getchar();
    while(d<'0'||d>'9'){
        if(d=='-') s=-1;
        d=getchar();
    }
    while(d>='0'&&d<='9'){
        a=a*10+d-'0';
        d=getchar();
    }
    return a*s;
}

void sol(){
    int q,w=0;
    for(int i=1;i<=a;i++){
        x[i]=read();
    }
    for(int i=1;i<=a;i++){
        for(int j=i-1;j>=1;j--)
            if(x[i]==x[j]){
                ans+=x[i];
                x[i]=x[j]=0;
        }
    }
    return;
}

int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int s=read();
    for(int i=1;i<=s;i++){
        ans=0;
        a=read();
        sol();
        cout<<ans<<endl;
    }
    return 0;
}



























/*Fly,My Wings(飞吧，我的翅膀)-Mili
  绽放E.G.O.:山茶花               */